/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package fwdisp.elements;

import fwdisp.MainFrame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Timer;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author rbs
 */
public class CountDownLabel extends fwdisp.elements.Label{

    int time;
    String str;
    public CountDownLabel(MainFrame m, final String str, int time_ms) {
        super(m);
        time = time_ms / 1000;
        /*Timer t = new Timer(1000, new ActionListener(){
        public void actionPerformed(ActionEvent e){
          time--;
          if(time>=0)
              setText(str + " " + time + " min");
          else System.exit(0);
        }
      });
      t.start();*/


    }

    public void run()
    {
        while(time > 60000)
        {
            this.setText(str + " " + time/60000 + " min");
            try {
                Thread.sleep(60000);
            } catch (InterruptedException ex) {
                Logger.getLogger(CountDownLabel.class.getName()).log(Level.SEVERE, null, ex);
            }
            time = time - 60000;
        }
    }

}
